
 define(function(require, exports, module) {

	  myApp  = seajs.data.vars.myApp;
	   
	   $$  = seajs.data.vars.dom;	
	 
	 
	

		 function page(){
				var _basePage=this;
				this.init=function(){
					 
					 		 
					
				   var url="/m/workmanage/approvelistajax";
				    
				    var tabobj =  null; 
				    
					
					//进度条
					 var container = $$('body');
		             if (container.children('.progressbar, .progressbar-infinite').length) return;  
		             myApp.showProgressbar(container, 'multi'); 
					
				 
					vueindex =	new Vue({
			            el:'#list',
			            data:{listdata:{},param:{keyWord:"",skipToPage:1 ,state:1,sp:"审批中"}},
			            created:function(){ 
			            	 
			            	mypagecount = 1;
			                var _self=this; 
			                $$.ajax({
			                	  url: url,
			                	  method:"POST",
			                	  async:false,
			                	  data:_self.param,
			                       success: function(data){
			                    	   if(data!=null&&data.length>1){
				                    	   _self.listdata=eval("(" + data +")");
				                    	   _self.param.skipToPage++;
				                    	    
			                    	   }
			                	  }
			                 })   
			            },
			            mounted:function(){
			            	setTimeout(function () {
			            		myApp.hideProgressbar();
						    }, 1000);
			            	  
			            },
			            beforeUpdate:function(){
			            	//  myApp.showProgressbar(container, 'multi');
			            }, 
			            updated:function(){
			            	//myApp.hideProgressbar()
			            },
			            methods: {
			    			reloaddata: function (obj) {
			    				 
			    				 if (container.children('.progressbar, .progressbar-infinite').length) return;  
			  		             myApp.showProgressbar(container, 'multi');  
			  		            
			    				 $$.ajax({
				                	  url: url,
				                	  method:"POST",
				                	  async:false,
				                	  data:vueindex.param,
				                       success: function(data){
				                    		   var b= null;
					                    	   if(vueindex.param.skipToPage==1){
					                    		  b = eval("(" + data +")");
					                    		  vueindex.listdata=b; 
						                    	  vueindex.param.skipToPage++;
					                    	   }else{
					                    		  
					                    		   if(data!=null&&data.length>3){   
					                    			   var a=new Array(); 
							                    	   b = a.concat(vueindex.listdata, eval("(" + data +")"));
							                    	   vueindex.listdata=b; 
							                    	   vueindex.param.skipToPage++;
					                    		   }else{
					                    			   myApp.toast().show("已全部加载!"); 	 
					                    		   } 
					                    	   } 
					                    	 
				                    	   setTimeout(function () {
							            		myApp.hideProgressbar();
										    }, 1000);
				                	  }
				                 })  
			    			},
			    			search:function(){
			    				reload();
			    				
			    			}
			    		}
			          });
					
					 
					
					$$('.aplistcon').on('infinite', function () {  
						  // 模拟1s的加载过程
						vueindex.reloaddata();  
						  
						});
						
					
				 
					// 添加'refresh'监听器
					$$('.aplistcon').on('refresh', function (e) {
						vueindex.param.skipToPage =1;
				        vueindex.reloaddata();  
					    // 模拟2s的加载过程
					    setTimeout(function () {
					    	
					        // 加载完毕需要重置
					        myApp.pullToRefreshDone();
					    }, 2000);
					});
					
					
				  
					var  reload= function(){
						vueindex.param.skipToPage =1;
					    
				        vueindex.reloaddata(); 
					 	setTimeout(function () { 
					        // 加载完毕需要重置
					        myApp.pullToRefreshDone();
					     }, 2000);
					}
					
					
				 
					$$('.cai-p-two').on('click', function () {
					    var buttons = [
					        {
					            text: '待审批',   
					            color:'gray',
					            onClick: function () {
					            	vueindex.param.state = 0;
					            	vueindex.param.sp ='待审批';
					            	reload();
					            }
					        },
					        {
					            text: '审批中',
					            color:'gray',
					            onClick: function () {
					            	vueindex.param.state = 1;
					            	vueindex.param.sp ='审批中';
					            	reload();
					            }
					        },
					        {
					            text: '通过',
					            color:'gray',
					            onClick: function () {
					            	vueindex.param.state = 2;
					            	vueindex.param.sp ='通过';
					            	reload();
				               }
					        },
					         {
					            text: '驳回',
					            color:'gray',
					            onClick: function () {
					            	vueindex.param.state = 3;
					            	vueindex.param.sp ='驳回';
					            	reload();
				                }
					        } 
					    ];
					    myApp.actions(buttons);
					});	 

					
				};
		 }		
		
		 module.exports=new page(); 
		 
	 				
})


